home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group00b.txt / 000129_icon-group-sender_Mon Oct 30 16:26:53 2000.msg < prev    next >
Internet Message Format  |  2001-01-03  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id e9UNQWH14118
  4.     for icon-group-addresses; Mon, 30 Oct 2000 16:26:32 -0700 (MST)
  5. Message-Id: <200010302326.e9UNQWH14118@baskerville.CS.Arizona.EDU>
  6. Date: Mon, 30 Oct 2000 20:49:57 +0000 (GMT)
  7. From: Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk>
  8. X-Sender: hgs@neelix
  9. To: symbiot@my-deja.com
  10. cc: Icon Group <icon-group@cs.arizona.edu>
  11. Subject: Re: How would the experts handle this...??
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13. Status: RO
  14. Content-Length: 1989
  15.  
  16. You wanted replies to be public, so...
  17. On Mon, 30 Oct 2000 symbiot@my-deja.com wrote:
  18.  
  19. > I wish to scan thru a file and determine how letters "connect" with one
  20. > Exmaple:
  21.     [...]
  22. > Here's how I have tackled the problem:
  23. > while line := read(data) do
  24. > {
  25. >    index := 0
  26. >    while index <= *line do
  27. >    {
  28.  
  29. Why are you doing all this work?  There is every to do this for you.
  30.  
  31. >    if not(line[index+1] == " ") then
  32. >         {
  33.  
  34. There is no else clause, so the test succeeds or fails.  Look at &
  35. to get the leverage off this feature
  36. >         centerchar := line[index+1]
  37. >     leftchar[centerchar] := leftchar[centerchar] || line[index]
  38. >     rightchar[centerchar] := rightchar[centerchar] || line[index +2]
  39. >     } #if not....
  40.  
  41. You won't need that
  42.  
  43. >     index +:= 1
  44. or this
  45.  
  46. >     # do it again
  47. >    }# end (while index <= *line)
  48. > }# end (while line := read(data))
  49.  
  50. or this.
  51. the same applies to the output.
  52.     [output section trimmed]
  53. > -----
  54. > Thus far, I have been roundly criticized by icon afficiandos for my use
  55. > of explicit indexing. It seems to me an intuitive way to handle the
  56.  
  57. Not so intuitive when you have to make sure you increment, etc.  The
  58. intuitive way is *not* to count the elements till you reach the end.  
  59. That is a roundabout way of saying process EVERY element in turn. Icon
  60. already understands "every".  It is not idiomatic Icon.  It gets the job
  61. done, but so does driving in first gear. :-)
  62.  
  63. > problems I've faced and makes the program "readable" to the layman.
  64.  
  65. Generally, the layman should not be reading your code. :-)  You should
  66. assume some fluency. If the point is subtle, write it clearly, but if
  67. it is a language feature, then just use it.  Yes, one can go overboard the
  68. other way.  One can do that in any language.
  69.  
  70. > But, be that as it may, I'm curious as to how those "in the know" would
  71. > handle this problem in a more "icon-esque" fashion.
  72. > Your suggestions are greatly appreciated.
  73. > Thanx!!
  74.     HTH
  75.     Hugh
  76.     hgs@dmu.ac.uk
  77.  
  78.